import request from '@/utils/request'

let assertsEntryUri="/common/dataassets"
let relationUrl="/common/dataassetsrelation";
// 查询下拉树结构
export function treeselect() {
  return request({
    url: assertsEntryUri+'/findAssetsAll',
    method: 'get'
  })
}

// 查询列表
export function listPossession(query) {
  return request({
    url: relationUrl+'/findRelationByAssetsId',
    method: 'get',
    params: query
  })
}

// 新增节点
export function addNode(data) {
  return request({
    url: assertsEntryUri+'/add',
    method: 'post',
    data: data
  })
}

// 修改节点
export function updateNode(data) {
  return request({
    url: assertsEntryUri+'/update',
    method: 'post',
    data: data
  })
}


// 删除节点
export function delNode(id) {
  return request({
    url: assertsEntryUri+'/deleteById',
    method: 'get',
    params:{assetsId:id},
  })
}

// 删除关联
export function unassociatePossession(nodeId,id) {
  return request({
    url: relationUrl+'/deleteById',
    method: 'get',
    params:{
      assetsId:nodeId,
      relationId:id,
    }
  })
}

export function associate(data){
  return request({
    url: relationUrl+'/add',
    method: 'post',
    data:data
  });
}


